<input type="hidden" value="OUINON" name="site[<?PHP echo $nb;?>]<?PHP if(isset($voxbloc)) echo '[bloc]['.$voxbloc.']';?>[question][<?PHP echo $question['id_question'];?>][type]" />
<div class="input_ouinon" style="clear:both;">
<?PHP $attributes = array('legend' => $question['libelle_question']);
	// on determine l'id des eventuelles reponses oui et non
	$reponse_oui = null;
	$reponse_non = null;
	// pour cela, on parcours les r�ponses
	foreach($question['reponses'] as $reponse) {
		if($reponse['id_reponse'] != null) {
			if($reponse['reponse_oui_non'] == true) $reponse_oui = $reponse;
			else if($reponse['reponse_oui_non'] == false) $reponse_non = $reponse;
		}
	}
?>
	<label><?PHP echo $question['libelle_question']; ?></label>

	<span>
		<input onchange="appliquerMoteur(<?PHP echo $nb;?>)" type="radio" <?PHP if($reponse_oui != null) echo ' id="site'.$nb.'_reponse_'.$reponse_oui['id_reponse'].'"'; ?>
				name="site[<?PHP echo $nb; ?>]<?PHP if(isset($voxbloc)) echo '[bloc]['.$voxbloc.']';?>[question][<?PHP echo $question['id_question']; ?>][val]" value="OUI" /> Oui
	</span>
	
	<span>
		<input onchange="appliquerMoteur(<?PHP echo $nb;?>)" type="radio" <?PHP if($reponse_non != null) echo ' id="site'.$nb.'_reponse_'.$reponse_non['id_reponse'].'"'; ?>
				name="site[<?PHP echo $nb; ?>]<?PHP if(isset($voxbloc)) echo '[bloc]['.$voxbloc.']';?>[question][<?PHP echo $question['id_question']; ?>][val]" value="NON" /> Non
	</span>
</div>

<script type="text/javascript">
	<?PHP if($reponse_oui != null): ?>
		ajouterFait(<?PHP echo $nb; ?>, 'site'+<?PHP echo $nb; ?>+'_reponse_'+<?PHP echo $reponse_oui['id_reponse']; ?>, document.getElementById('site'+<?PHP echo $nb; ?>+'_reponse_'+<?PHP echo $reponse_oui['id_reponse']; ?>));
		baseDeFait[<?PHP echo $nb; ?>]['site'+<?PHP echo $nb; ?>+'_question_'+<?PHP echo $question['id_question']; ?>+"_reponses"].push(document.getElementById('site'+<?PHP echo $nb; ?>+'_reponse_'+<?PHP echo $reponse_oui['id_reponse']; ?>));
	<?PHP endif; ?>
	<?PHP if($reponse_non != null): ?>
		ajouterFait(<?PHP echo $nb; ?>, 'site'+<?PHP echo $nb; ?>+'_reponse_'+<?PHP echo $reponse_non['id_reponse']; ?>, document.getElementById('site'+<?PHP echo $nb; ?>+'_reponse_'+<?PHP echo $reponse_non['id_reponse']; ?>));
		baseDeFait[<?PHP echo $nb; ?>]['site'+<?PHP echo $nb; ?>+'_question_'+<?PHP echo $question['id_question']; ?>+"_reponses"].push(document.getElementById('site'+<?PHP echo $nb; ?>+'_reponse_'+<?PHP echo $reponse_non['id_reponse']; ?>));
	<?PHP endif; ?>
</script>
<script type="text/javascript">
<?PHP
	// ajout des actions li�s aux r�ponses oui � la base de r�gles
	foreach($question['reponses'] as $reponse) {
		foreach ($reponse['actions'] as $action) {
			// si l'action revient � activer une question
			if($action['active_question']) {
				// on affiche l'élément si active_question vaut true
?>
	ajouterRegle(function(){return $(baseDeFait[<?PHP echo $nb;?>]['site'+<?PHP echo $nb; ?>+'_question_'+<?PHP echo $question['id_question'];?>]).is(':visible') && baseDeFait[<?PHP echo $nb;?>]['site'+<?PHP echo $nb; ?>+'_reponse_'+<?PHP echo $reponse['id_reponse'];?>].checked;}, function(){afficherElement(<?PHP echo $nb;?>, 'site'+<?PHP echo $nb; ?>+'_question_'+<?PHP echo $action['id_question']; ?>);});
<?PHP
			}
			else {
				// on cache l'élément si active_question vaut false
?>
	ajouterRegle(function(){return $(baseDeFait[<?PHP echo $nb;?>]['site'+<?PHP echo $nb; ?>+'_question_'+<?PHP echo $question['id_question'];?>]).is(':visible') && baseDeFait[<?PHP echo $nb;?>]['site'+<?PHP echo $nb; ?>+'_reponse_'+<?PHP echo $reponse['id_reponse'];?>].checked;}, function(){cacherElement(<?PHP echo $nb;?>, 'site'+<?PHP echo $nb; ?>+'_question_'+<?PHP echo $action['id_question']; ?>);});
<?PHP
			}
		}
		// on parcours également son tableau de change_statut
		foreach($reponse['change_statut'] as $change_statut) {
			// on ajoute au script le changement de statut
			echo "ajouterRegle(function(){return $(baseDeFait[$nb]['site'+$nb+'_question_'+".$question['id_question']."]).is(':visible') && baseDeFait[$nb]['site'+$nb+'_reponse_'+".$reponse['id_reponse']."].checked;}, function(){changerStatut(".$nb.", 'site".$nb."_reponse_".$change_statut['id_reponse_statut_change_par']."', '".$change_statut['libelle_statut']."', ".$change_statut['priorite'].");});\n";
		}
	}
?>
</script>